<?php

class CallbackController extends Zend_Controller_Action
{

	public function init()
	{
		/* Initialize action controller here */
            
	}

	public function indexAction()
	{
	    	$this->_helper->Layout->disableLayout();	
            $storage = new Zend_Feed_Pubsubhubbub_Model_Subscription;
		$callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;
		$callback->setStorage($storage);
		/**
		 * Inject subscription key parsing from URL path using
		 * a parameter from Router.
		 */
		$subscriptionKey = $this->_getParam('subkey');
		$callback->setSubscriptionKey($subscriptionKey);
		$callback->handle();
		$callback->sendResponse();

		/**
		 * Check if the callback resulting in the receipt of a feed update.
		 * Otherwise it was either a (un)sub verification request or invalid
		 * request. Typically we need do nothing other than add feed update
		 * handling - the rest is handled internally by the class.
		 */
		if ($callback->hasFeedUpdate()) {
			$feedString = $callback->getFeedUpdate();
			/**
			 *  Process the feed update asynchronously to avoid a Hub timeout.
			 */
		}
	}
}
